<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/img/admin.png}">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>TeamA6 | 商品目录管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/administration/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/administration/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/administration/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <link rel="stylesheet" th:href="@{/administration/bootstrap-table/bootstrap-table.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/administration/adminlte/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/administration/adminlte/css/skins/_all-skins.min.css}">
    <link rel="stylesheet" th:href="@{/administration/layui/layui.css}">

    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>




    <script th:src="@{/administration/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
    <script th:src="@{/administration/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- FastClick -->
    <script th:src="@{/administration/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
    <!-- AdminLTE App -->
    <script th:src="@{/administration/adminlte/js/adminlte.min.js}"></script>
    <!-- AdminLTE for demo purposes -->
    <script th:src="@{/administration/adminlte/js/demo.js}"></script>


    <script th:src="@{/administration/bootstrap-table/bootstrap-table.min.js}"></script>
    <script th:src="@{/administration/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <!--    引入公共类头部文件-->
    <div th:replace="administration/common/bar::topbar"></div>
    <!-- 左侧菜单页面-->

    <div th:replace="administration/common/bar::#sidebar"></div>

    <!--不能抽取的内容显示页-->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                网上购物商城
                <small>后台管理</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li><a href="#">商品模块</a></li>
                <li class="active">商品目录管理</li>
            </ol>
        </section>

        <!-- Main content -->
        <!--        <div class="col-md-6 col-md-offset-3">.col-md-6 .col-md-offset-3</div>-->
        <section class="content">
            <div class="row">
                <div class="col-md-6 col-md-offset-3">
                    <h1 id="h1_text" style="color:#3c8dbc;text-align: center">新增活动</h1>
                    <form method="post" action="/adminActivity/addActivity" name="myform" onSubmit="return myCheck()">
                        <input id="activityEditIden" type="hidden" th:value="${activityEdit}==null?'' : ${activityEdit.getActivityId()} " name="activityId"/>
                        <div class="form-group">
                            <label for="exampleInputEmail1" style="color:#3c8dbc">商品：</label>
                            <select name="productId" id="exampleInputEmail1" class="form-control">
                                <option th:value="${activityEdit}==null?'':${activityEdit.getProductId()}" th:text="${activityEdit}==null ? '请输入商品名称' : ${activityEdit.getActivitytName()} ">请输入商品名称</option>
                                <option th:each="product : ${products}" name="productId" th:value="${product.getProductId()}" th:text="${product.getProductName()}">2</option>


                            </select>

                            <!--                            <input type="text" name="ptypeId" class="form-control" id="exampleInputEmail1" placeholder="商品类型ID">-->
                        </div>
                        <div class="form-group">
                            <label for="exampleInputName" style="color:#3c8dbc">活动描述：</label>
                            <input type="text" name="activityDescribe" th:value="${activityEdit}==null?'' : ${activityEdit.getActivityDescribe()}" class="form-control" id="exampleInputName" placeholder="活动描述">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPrice" style="color:#3c8dbc">折扣价格：</label>
                            <input type="number"  min="0.00" step="0.01" name="discountPrice" th:value="${activityEdit}==null?'' : ${activityEdit.getDiscountPrice()}" class="form-control" id="exampleInputPrice" placeholder="折扣价格">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputDescription" style="color:#3c8dbc">活动开始时间：</label>
                            <input type="text" class="layui-input" name="timeStart" th:value="${activityEdit}==null?'' : ${activityEdit.getTimeStart()}" id="exampleInputDescription" placeholder="活动开始时间">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPostPrice" style="color:#3c8dbc">活动结束时间：</label>
                            <input type="text" class="layui-input" name="timeEnd" th:value="${activityEdit}==null?'' : ${activityEdit.getTimeEnd()}" id="exampleInputPostPrice" placeholder="活动结束时间">
                        </div>
                        <div class="row">
                            <div  class="col-md-6"><button type="submit" id="submit_btn" class="btn btn-info" style="color:#fff;margin-left: 200px">新增</button></div>
                            <div class="col-md-6"><button type="button"  class="btn btn-info"  style="color:#fff;"><a
                                    th:href="@{/adminActivity/activityList}" style="color: white">取消</a></button></div>
                        </div>
                    </form>
                </div>
            </div>

            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>

    <!--尾部代码-->
    <div th:replace="administration/common/bar::#footerbar"></div>

    <!--控制代码-->
    <!--    <div th:replace="administration/common/bar::#controlbar"></div>-->
</div>
<script th:src="@{/administration/laydate/laydate.js}"></script>
<script th:src="@{/layer-v3.1.1/layer/layer.js}"></script>
<script th:inline="javascript">
    $(document).ready(function(){
        if($('#activityEditIden').val() != ''){
            $("#h1_text").text("修改商品")
            $("#submit_btn").text("修改")
        }
        if($("#exampleInputDescription").val() != ""){
            var d = new Date( $("#exampleInputDescription").val() );
            var startTime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
            $('#exampleInputDescription').val(startTime)
        }else {
            $("#exampleInputDescription").val("");
        }
        if ($("#exampleInputPostPrice").val() !=""){
            var d = new Date( $("#exampleInputPostPrice").val() );
            var endTime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
            $('#exampleInputPostPrice').val(endTime)
        }else {
            $("#exampleInputPostPrice").val("");
        }

        var msg = [[${msg}]];
        if (msg =="exist"){
            layer.msg("商品已经存在");
        }


    });

    //时间选择器
    laydate.render({
        elem: '#exampleInputDescription'
        ,type: 'datetime',
        trigger:'click'
    });
    //时间选择器
    laydate.render({
        elem: '#exampleInputPostPrice'
        ,type: 'datetime',
        trigger:'click'
    });
    $("#cancel").click(function () {
        window.history.back(-2);
    })
</script>
<script th:inline="javascript">
     function myCheck()
     {

         if (document.myform.productId.value==""){
             layer.msg("请输入商品ID")
             document.myform.productId.focus();
             return false;
         }else if (document.myform.activityDescribe.value==""){
             layer.msg("请输入活动描述")
             document.myform.activityDescribe.focus();
             return false;
         }else if (document.myform.discountPrice.value==""){
            layer.msg("请输入折扣价格")
            document.myform.discountPrice.focus();
            return false;
        }else if (document.myform.timeStart.value==""){
             layer.msg("请输入活动开始时间")
             document.myform.timeStart.focus();
             return false;
         }else if(document.myform.timeEnd.value==""){
             layer.msg("请输入活动结束时间")
             document.myform.timeEnd.focus();
             return false;
         }else {
             return true;
         }

     }

</script>
</body>
</html>
